package com.sy.structural.composite;

import java.util.ArrayList;
import java.util.List;

public class Menu {

    private String name;

    private int id;

    private List<Menu> childMenu = new ArrayList<>();

    public void printMenu() {
        System.out.println(name);
        if (childMenu.size() > 0) {
            for (Menu child : childMenu) {
                child.printMenu();
            }
        }
    }

    public void addMenu(Menu menu) {
        childMenu.add(menu);
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public List<Menu> getChildMenu() {
        return childMenu;
    }

    public void setChildMenu(List<Menu> childMenu) {
        this.childMenu = childMenu;
    }

    public Menu(String name, int id) {
        this.name = name;
        this.id = id;
    }
}
